app=$1


if [ "$app" == "" ]; then 
  echo "./run-11.sh 目录名"
  exit 1;
fi

app=`echo ${app//\//}`


start_sh="/app/java/start.sh"
if [ -f "/app/java/$app/start.sh" ]; then 
    start_sh="/app/java/$app/start.sh"
    echo "start脚本: $start_sh"
fi

host_ip=$(docker network inspect bridge | grep Gateway | awk '{print $NF}' | sed 's/"//g')

docker kill $app ; docker rm $app

if [ "$app" == "user-center" ]; then
   vp=" $vp -p 9999:9999 "
fi

if [ "$app" == "uc-ext-backend" ]; then
   vp=" $vp -p 9988:9988 "
fi

echo "正在启动 $app ..."
docker run   --name $app --net vm \
  -m 1024m -d \
  $vp \
  -v "$(pwd)/$app":/app \
  -v  "$(pwd)/u-hosts.sh":/app/u-hosts.sh  \
  -v "$start_sh":/app/exec.sh \
  -w /app  \
  --add-host=nacos:172.17.134.92 \
  --add-host=dc-app:$host_ip \
  --add-host=amy:172.17.134.92 \
  --add-host=dc-qq:43.143.250.229 \
  --add-host=mysql:172.17.134.92 \
  --add-host=mongo:172.17.134.92 \
  --add-host=redis:172.17.134.92 \
  --add-host=rabbitmq:172.17.134.92 \
  --add-host=es:172.17.134.92 \
  --add-host=minio:172.17.134.92 \
  openjdk:11  /bin/bash  /app/exec.sh $app
